package device

import (
	"dev_gw/point"
	pointtable "dev_gw/pointTable"
)

type Device struct {
	id uint32
	pt pointtable.PointTable
}

func NewDevice() *Device {
	return &Device{
		id: 10000,
		pt: pointtable.NewPointTable(),
	}
}

func (d *Device) Insert(name string, p point.PointInterface) pointtable.PointTable {
	return d.pt.Insert(name, p)
}

func (d *Device) HasPoint(name string) bool {
	return d.pt.FindPoint(name) != nil
}

func (d *Device) PointValue(name string) any {
	return d.pt.FindPoint(name).Get()
}

func (d *Device) WritePoint(name string, value ...any) bool {
	return d.pt.FindPoint(name).Set(value...)
}

func (d *Device) Id() uint32 {
	return d.id
}
